module.exports = (app) => {
  const { STRING, INTEGER, DECIMAL, DATE, NOW } = app.Sequelize

  const Goods = app.model.define(
    't_goods',
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: '商品主键'
      },
      user_id: {
        type: INTEGER,
        allowNull: false,
        comment: '用户外键'
      },
      type_id: {
        type: INTEGER,
        allowNull: false,
        comment: '分类外键'
      },
      name: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
        comment: '商品名'
      },
      price: {
        type: DECIMAL(8, 2),
        allowNull: false,
        defaultValue: 0,
        comment: '商品价格'
      },
      photo: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
        comment: '商品图片'
      },
      num: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '供应量'
      },
      descript: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
        comment: '商品描述'
      },
      created_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '创建时间'
      },
      updated_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '更新时间'
      }
    },
    {
      freezeTableName: true, // Model 对应的表名将与model名相同
      timestamps: false
    }
  )
  return Goods
}
